package com.gmail.mariska.martin.service;

import org.apache.log4j.Logger;

import com.google.common.util.concurrent.Service;
import com.google.common.util.concurrent.Service.Listener;
import com.google.common.util.concurrent.Service.State;

public class ServiceListener implements Listener {
	static final Logger logger = Logger.getLogger(ServiceListener.class);
	private final Service listenService;

	public ServiceListener(Service service) {
		this.listenService = service;
	}

	@Override
	public void starting() {
		logger.info("service is starting " + listenService.toString());
	}

	@Override
	public void running() {
		logger.info("service is running " + listenService.toString());
	}

	@Override
	public void stopping(State from) {
		logger.info("service is stopping from state: " + from + "  - " + listenService.toString());
	}

	@Override
	public void terminated(State from) {
		logger.info("service is terminated from state: " + from + "  - " + listenService.toString());
	}

	@Override
	public void failed(State from, Throwable failure) {
		logger.info("service is failed from state: " + from + "  - " + listenService.toString());
	}

}
